<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <t:base type="jquery,easyui,tools,DatePicker,ckeditor"></t:base>
    <link rel="stylesheet" href="${webRoot}/plug-in/lhgDialog/skins/blue.css"/>
    <link rel="stylesheet" href="${webRoot}/plug-in/lhgDialog/skins/default.css"/>
    <script type="text/javascript" src="${webRoot}/plug-in/ajaxfileupload/ajaxfileupload.js"></script>
    <script type="text/javascript" charset="utf-8"
            src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8"
            src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/ueditor.all.min.js"></script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8"
            src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/QQgeo/geo.js"></script>
    <script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        //Ajax文件上传
        function f_file_upload(fileInputId, imgId, valueId) {
            var path = $("#" + fileInputId).val();

            var pos1 = path.lastIndexOf("\\");
            var pos2 = path.lastIndexOf(".");

            var fileName = path.substring(pos1 + 1, pos2);

            var result = path.substring(pos2 + 1, path.length);

            var imgs = ".bmp.jpg.dib.jpeg.png.jfif.jpe.tif.tiff.gif.BMP.JPG.DIB.JPEG.PNG.JFIF.JPE.TIF.TIFF.GIF";
            //文件类型 false为压缩包
            var boo = false;
            if (imgs.indexOf(result) > -1) {
                boo = true;
            } else {
                tip(" 只能上传后缀为 " + imgs + " 的文件！");
                $("#" + fileInputId).val("");
                return;
            }

            $.ajaxFileUpload({
                url: '${webRoot}/myFileUpload/uploadImageScale.do',
                secureuri: false,
                fileElementId: fileInputId,
                //dataType: 'json',
                success: function (data) {
                    var data2 = data.split(",");
                    var url = data2[0].replace(" ", "");
                    fileName = data2[1].replace(" ", "");

                    $("#" + imgId).attr("src", "${webRoot}/" + url);
                    $("#" + valueId).val(url);
                },
                error: function (data) {

                    console.log("error");
                    console.log(data);
                }
            });
        }
    </script>
</head>
<body scroll="no">
<t:formvalid formid="addformobj" dialog="true" usePlugin="password" layout="table"
             action="questController.do?saveorupdate">
    <input name="id" type="hidden" value="${entity.id}">

    <div class="new_table_list">
        <table cellpadding="0" cellspacing="0" class="formtable">
            <tbody>
            <tr>
                <th colspan="2">量表信息</th>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        量表名称:
                    </label>
                </td>
                <td class="txt_left value">
                    <input class="inputxt" style="width: 250px;" name="name" value="${entity.name}" datatype="*"
                           maxlength="128">
                    <span class="Validform_checktip"></span>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        量表分类:
                    </label>
                </td>
                <td class="txt_left value">
                    <input id="cc" name="questSortEntity.name" value="${entity.questSortEntity.name}">
                    <input id="pp" name="questSortEntity.qsId" hidden="hidden" value="${entity.questSortEntity.qsId}" datatype="*">
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        所属平台:
                    </label>
                </td>
                <td class="txt_left value">
                    <input type="hidden" id="platformId" name="platformEntity.platformId"
                           value="${entity.platformEntity.platformId}">
                    <input type="inputxt" id="showName"
                           value="${entity.platformEntity.name}"
                           readonly="readonly" nullmsg='请选择' style="width: 150px;" datatype="*">
                    <t:choose name="platformList" hiddenName="platformId" hiddenid="platformId"
                              url="platformController.do?selectList"
                              icon="icon-search" title="选择咨询师" inputTextname="showName"
                              textname="name" isclear="false" width="600px" height="450px" fun=""></t:choose>
                    <span class="Validform_checktip"></span>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        展示方式:
                    </label>
                </td>
                <td class="txt_left value">
                    <t:dictSelect id="showType" field="showType" typeGroupCode="showType"
                                  defaultVal="${entity.showType}" hasLabel="false"></t:dictSelect>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        是否模版:
                    </label>
                </td>
                <td class="txt_left value">
                    <t:dictSelect id="template" field="template" typeGroupCode="isno"
                                  defaultVal="${entity.template}" hasLabel="false"></t:dictSelect>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        是否有效:
                    </label>
                </td>
                <td class="txt_left value">
                    <t:dictSelect id="effective" field="effective" typeGroupCode="isno"
                                  defaultVal="${entity.effective}" hasLabel="false"></t:dictSelect>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        心询量表:
                    </label>
                </td>
                <td class="txt_left value">
                    <t:dictSelect id="isShow" field="isShow" typeGroupCode="isno"
                                  defaultVal="${entity.isShow}" hasLabel="false"></t:dictSelect>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        首页展示:
                    </label>
                </td>
                <td class="txt_left value">
                    <t:dictSelect id="homeShow" field="homeShow" typeGroupCode="homeShow"
                                  defaultVal="${entity.homeShow}" hasLabel="false"></t:dictSelect>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        指导语:
                    </label>
                </td>
                <td class="txt_left value">
                    <textarea style="width: 98%;height: 100px;" name="glanguage" datatype="*">${entity.glanguage}</textarea>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        简介:
                    </label>
                </td>
                <td class="txt_left value">
                    <textarea style="width:98%;height: 100px;" name="brief">${entity.brief}</textarea>
                </td>
            </tr>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        背景图:
                    </label>
                </td>
                <td class="txt_left value">
                    <img id="backgroudThumbImg"
                         src='${webRoot}/${entity.backgroud==null||entity.backgroud==''?"upload/none.jpg":entity.backgroud}'
                         class="viewimg" alt="预览" title="预览" width="200px;" height="100px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file" id="backgroud"
                           onchange="f_file_upload('backgroud','backgroudThumbImg','backgroudThumb')"/>
                    <input type="hidden" name="backgroud" id="backgroudThumb"
                           value='${entity.backgroud}'/>
                </td>
            </tr>
        </table>
    </div>
</t:formvalid>
<script type="text/javascript">
    $(function () {
        $("#showType").children().first().remove();
        $("#template").children().first().remove();
        $("#effective").children().first().remove();
        $("#isShow").children().first().remove();
        $("#homeShow").children().first().remove();

        $('#cc').combotree({
            url: 'questSortController.do?setPFunction',
            width: 155,
            onSelect: function (node) {
                $("#cc").val(node.text);
                $("#pp").val(node.id);
            }
        });
    });
</script>
</body>

</html>